/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package icexam.exam;

import icexam.dao.IssueDao;
import java.util.ArrayList;

/**
 *
 * @author Ethan
 */
public class QuestionHelper {
    public ArrayList<Issue> loaderForExam(){
        ArrayList<Issue> ques = new ArrayList<Issue>();
        ArrayList<Issue> selectIS  = new IssueDao().getAllIssue(0);
        int selectSize = 0;
        while(selectSize<40){
            int tmp = (int) Math.round(Math.random()*selectIS.size());
            if(tmp!=0)
                tmp = selectIS.size()%tmp;
            Issue is = selectIS.get(tmp);
            ques.add(is);
            selectIS.remove(is);
            selectSize++;
        }
        selectIS  = new IssueDao().getAllIssue(1);
        selectSize = 0;
        while(selectSize<10){
            int tmp = (int) Math.round(Math.random()*selectIS.size());
            if(tmp!=0)
                tmp = selectIS.size()%tmp;
            Issue is = selectIS.get(tmp);
            ques.add(is);
            selectIS.remove(is);
            selectSize++;
        }

        return ques;
    }
    public static void main(String[] args){
        ArrayList<Issue> is  = new QuestionHelper().loaderForExam();
        System.out.println(is.size());
        for(Issue i : is){
//            if(i.getQid()<10)
            System.out.println(i.getQid());
        }
    }
    public ArrayList<Issue> loaderAll(){
        
//        ArrayList<Issue> ques = new ArrayList<Issue>();
//        ArrayList<Issue> selectIS  = new IssueDao().getAllIssue();
        return new IssueDao().getAllIssue();
//        int selectSize = 0;
//        while(selectSize<40){
//            int tmp = (int) Math.round(Math.random()*selectIS.size());
//            if(tmp!=0)
//                tmp = selectIS.size()%tmp;
//            Issue is = selectIS.get(tmp);
//            ques.add(is);
//            selectIS.remove(is);
//            selectSize++;
//        }
//        selectIS  = new IssueDao().getAllIssue(1);
//        selectSize = 0;
//        while(selectSize<10){
//            int tmp = (int) Math.round(Math.random()*selectIS.size());
//            if(tmp!=0)
//                tmp = selectIS.size()%tmp;
//            Issue is = selectIS.get(tmp);
//            ques.add(is);
//            selectIS.remove(is);
//            selectSize++;
//        }
//
//        return ques;
    }
}
